package com.example.s.Activity.team;

import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.s.Activity.BaseActivity;
import com.example.s.R;
import com.example.s.adapter.InnerHolder;
import com.example.s.adapter.MyRecyclerViewAdapter;
import com.example.s.bean.MessageTeam;

import java.util.ArrayList;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

public class TeamMessageActivity extends BaseActivity {
    private ImageView back;
    private TextView title;
    private ImageView titleIcon;
    private RecyclerView rv;
    private List<MessageTeam> mMessageTeamList = new ArrayList<>();
    private MyRecyclerViewAdapter<MessageTeam> mMessageAdapter;

    private void initView() {

        back = (ImageView) findViewById(R.id.back);
        title = (TextView) findViewById(R.id.title);
        titleIcon = (ImageView) findViewById(R.id.titleIcon);
        rv = (RecyclerView) findViewById(R.id.rv);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message_child_common);
        initView();
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        title.setText("组队消息");
        titleIcon.setBackgroundResource(R.mipmap.message_team);
        setTeamMessageData();
        rv.setLayoutManager(new LinearLayoutManager(this));
        rv.setAdapter(mMessageAdapter = new MyRecyclerViewAdapter<MessageTeam>(mMessageTeamList, R.layout.activity_messageteam) {
            @Override
            public void handleData(InnerHolder holder, MessageTeam item) {
                holder.setSrcResource(R.id.headphoto, R.mipmap.ic_launcher); //修改头像
                holder.setText(R.id.name, item.getmName());
                holder.setText(R.id.content, item.getmContent());
                holder.setText(R.id.time, item.getmTime());
                if (item.getmMessagestate() == 1) {
                    holder.setText(R.id.state, "请求加入您的组队");
                    holder.setVisibility(R.id.agreeOrAgreed, true);
                    holder.setText(R.id.agreeOrDisagreeOrExamine, "同意");
                    holder.setImageResource(R.id.agreeOrDisagreeOrExamine, R.drawable.team_agree);
                    holder.setTextColor(R.id.agreeOrDisagreeOrExamine, "#FF38F600");
                } else if (item.getmMessagestate() == 2) {

                    holder.setText(R.id.state, "组队审核已被通过");
                    holder.setVisibility(R.id.agreeOrAgreed, false);
                    holder.setText(R.id.agreeOrDisagreeOrExamine, "已同意");
                    holder.setImageResource(R.id.agreeOrDisagreeOrExamine, R.drawable.team_agree);
                    holder.setTextColor(R.id.agreeOrDisagreeOrExamine, "#FF38F600");
                } else if (item.getmMessagestate() == 3) {

                    holder.setText(R.id.state, "组队审核已被拒绝");
                    holder.setVisibility(R.id.agreeOrAgreed, false);
                    holder.setText(R.id.agreeOrDisagreeOrExamine, "已拒绝");
                    holder.setImageResource(R.id.agreeOrDisagreeOrExamine, R.drawable.message_attentiont);
                    holder.setTextColor(R.id.agreeOrDisagreeOrExamine, "#fffc4545");
                } else if (item.getmMessagestate() == 4) {
                    holder.setText(R.id.state, "您的组队正在审核");
                    holder.setVisibility(R.id.agreeOrAgreed, false);
                    holder.setText(R.id.agreeOrDisagreeOrExamine, "审核中");
                    holder.setImageResource(R.id.agreeOrDisagreeOrExamine, R.drawable.team_examine);
                    holder.setTextColor(R.id.agreeOrDisagreeOrExamine, "#ffffff");
                }


            }
        });
    }

    private void setTeamMessageData() {
        mMessageTeamList.add(new MessageTeam("", "杨叶文", "2小时", "组队:一起去看java", 1));
        mMessageTeamList.add(new MessageTeam("", "杨叶文", "2小时", "组队:一起去看java", 2));
        mMessageTeamList.add(new MessageTeam("", "杨叶文", "2小时", "组队:一起去看java", 3));
        mMessageTeamList.add(new MessageTeam("", "杨叶文", "2小时", "组队:一起去看java", 4));
        mMessageTeamList.add(new MessageTeam("", "杨叶文", "2小时", "组队:一起去看java", 1));
    }


}
